import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import refresh from '@dfeidao/atom-web/url/refresh';
import a003 from './a003';
export default async function a002(fd: IFeidaoAiBrowserComponent) {// 删除操作
	// todo
	console.log('zj-000011：a002----start');
	const nos = get(fd, 'nos') as string[];
	const hno = get(fd, 'hidden2') as string[];
	console.log('隐患源编号', nos);
	console.log('隐患源特性编号', hno);
	if (hno) {
		const res = await nodejs<{ code: 0 | 1; result: string }>('wyf-hManager/zj-000011/s002', {// 隐患源特性表的删除
			hidden_source: nos,
			hidden_source_feature_no: hno
		});
		if (res.code === 1) {
			alert('删除成功');
			await a003(fd);
			// refresh();
			fire('zj-000006', 'a001', nos[0]);

		} else {
			alert('删除失败');
		}
	} else {
		const res1 = await nodejs<{ code: 0 | 1; result: string }>('wyf-hManager/zj-000011/s001', {
			hidden_source: nos
		});
		if (res1.code === 1) {
			alert('删除成功');
			await a003(fd);
			refresh();
		} else {
			alert('删除失败');
		}
	}

	console.log('zj-000011:a002----end');
}

